
function TableWithConsole(tableDivId, consoleDivId) { 
    this.table;
    this.tableDivId = tableDivId;
    this.consoleDivId = consoleDivId;
}

// Add methods like this.  All Person objects will be able to invoke this
TableWithConsole.prototype.initTable = function(aocolumns, onRowClick) {
    $(this.tableDivId).DataTable({ 
        bFilter: false,
        bInfo: false,
        "bPaginate": false,
        pagination: false,
        "aaData": [],
        "aoColumns": aocolumns
    });
    this.table = $(this.tableDivId).dataTable(); 
    this.addOnRowClick(this.table, onRowClick);
    
};

TableWithConsole.prototype.addOnRowClick = function(table, onRowClick) { 
    if (onRowClick !== null) {
        var id = this.tableDivId + " tbody"; 
        $(id).delegate("tr", "click", function() { 
            var iPos = table.fnGetPosition(this);
            var aData = table.fnGetData(iPos);
            onRowClick.call(this, aData);
        });
    } 
}; 

TableWithConsole.prototype.loadTable = function(array) {
    this.table.fnClearTable();
    this.table.fnAddData(array);
}

TableWithConsole.prototype.log = function(txt) {
    console.log(txt);
    $(this.consoleDivId).prepend(txt + '<br>');
};